// ==================== src/error.rs ====================
//! 错误类型定义

use thiserror::Error;

/// Nacos核心错误类型
#[derive(Debug, Error)]
pub enum NacosError {
    #[error("存储错误: {0}")]
    Storage(String),
    
    #[error("网络错误: {0}")]
    Network(String),
    
    #[error("配置错误: {0}")]
    Config(String),
    
    #[error("服务发现错误: {0}")]
    Naming(String),
    
    #[error("集群错误: {0}")]
    Cluster(String),
    
    #[error("序列化错误: {0}")]
    Serialization(#[from] serde_json::Error),
    
    #[error("验证错误: {0}")]
    Validation(String),
    
    #[error("权限错误: {0}")]
    Permission(String),
    
    #[error("资源不存在: {0}")]
    NotFound(String),
    
    #[error("资源已存在: {0}")]
    AlreadyExists(String),
    
    #[error("超时错误")]
    Timeout,
    
    #[error("未知错误: {0}")]
    Unknown(String),

    #[error("功能不支持")]
    Unsupported,

    #[error("内部错误: {0}")]
    Internal(String),

    #[error("协议错误: {0}")]
    Protocol(String),

    #[error("路由错误: {0}")]
    Route(String),
}

/// 统一的Result类型
pub type Result<T> = std::result::Result<T, NacosError>;